import java.io.PrintWriter;
import java.util.Scanner;
/*********************************************************************
 * Lab 08:  Assemble packets into a meessage
 * @author Duncan Buell
 * 15 March 2009
**/
public class Main
{

  public static void main(String[] args)
  {
    Scanner inFile = null;
    PrintWriter outFile = null;
    PacketAssembler assembler = null;

    inFile = FileUtils.ScannerOpen("zin.gett.scrambled");
    outFile = FileUtils.PrintWriterOpen("zoutFile");
    FileUtils.setLogFile("zlogFile");

/*********************************************************************
 * For this program, we are writing code that will essentially
 * run forever, so we simply invoke the class and let it go rather
 * than try to control execution from the main.  A real packet
 * assembler is always "in execution" although it may be sleeping
 * while waiting for more input to arrive.  We will not insist
 * that this program goes to sleep, though.  We will simply let
 * it run until it has no more input.
**/
    assembler = new PacketAssembler();
    assembler.readPackets(inFile);
    assembler.writePackets(outFile);

/*********************************************************************
 * close up and go home
**/
    FileUtils.closeFile(inFile);
    FileUtils.logFile.printf("No more input, terminate%n");
    FileUtils.closeLogFile();
  }
} // public class Main
